package the.world.util;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

//统一结果类处理
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Result<T> {
    private int code;
    private String massage;
    private T[] data;
    private int totalPage;
    public static <T> Result<T> ok(T[] date,String message,int totalPage) {
        Result<T> result = new Result<T>();
        result.setData(date);
        result.setCode(StatusCode.LOSE.getValue());
        result.setMassage(message);
        result.setTotalPage(totalPage);
        return result;
    }
    public static <T> Result<T> ok(T[] date,String message) {
        Result<T> result = new Result<T>();
        result.setData(date);
        result.setCode(StatusCode.LOSE.getValue());
        result.setMassage(message);
        return result;
    }
    public static <T> Result<T> error(String message) {
        Result<T> result = new Result<T>();
        result.setCode(StatusCode.LOSE.getValue());
        result.setMassage(message);
        return result;
    }
}
